<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 参考 https://juejin.cn/post/6844903665308794888
      function curry(fn, args) {
        debugger;
        // 获取fn的参数的个数
        var length = fn.length;
        var args = args || [];
        return function () {
          newArgs = args.concat(Array.prototype.slice.call(arguments));
          if (newArgs.length < length) {
            return curry.call(this, fn, newArgs);
          } else {
            return fn.apply(this, newArgs);
          }
        };
      }
      function multiFn(a, b, c) {
        return a * b * c;
      }
      var multi = curry(multiFn);
      multi(2)(3)(4);
      //   multi(2, 3, 4);
      //   multi(2)(3, 4);
      //   multi(2, 3)(4);
    </script>
  </body>
</html>
